package com.softstao.guoyu.mvp.interactor.me;

import com.softstao.guoyu.global.APIInterface;
import com.softstao.guoyu.model.me.AddressCondition;
import com.softstao.guoyu.model.me.AddressList;
import com.softstao.guoyu.model.me.AreaList;
import com.softstao.guoyu.mvp.interactor.BaseInteractor;
import com.softstao.guoyu.utils.MyHttpParams;

import rx.functions.Action1;

/**
 * Created by vaikus on 2017/6/22.
 */

public class AddressInteractor extends BaseInteractor {
    public void getAddress(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.ADDRESS_LIST)
                .setType(AddressList.class)
                .getVolley()
                .post(params);
    }

    public void changeDefault(int agentId, int addressId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "addressId", addressId);
        builder.setAction(action1)
                .setUrl(APIInterface.CHANGE_DEFAULT_ADDRESS)
                .setType(AddressList.class)
                .getVolley()
                .post(params);
    }

    public void deleteAddress(int agentId, int addressId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "addressId", addressId);
        builder.setAction(action1)
                .setUrl(APIInterface.DELETE_ADDRESS)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void addAddress(AddressCondition condition,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        builder.setAction(action1)
                .setUrl(APIInterface.ADD_ADDRESS)
                .setType(AddressList.class)
                .getVolley()
                .post(params);
    }

    public void getArea(String provinceCode,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("provinceCode",provinceCode);
        builder.setAction(action1)
                .setUrl(APIInterface.LINK_PROVINCE_CITY)
                .setType(AreaList.class)
                .getVolley()
                .post(params);
    }
}
